package com.base.cn.platform.os.service.manage.count;

import com.base.cn.platform.os.common.mybatis.BaseBiz;
import com.base.cn.platform.os.common.utils.DateUtils;
import com.base.cn.platform.os.common.utils.ObjectUtils;
import com.base.cn.platform.os.dao.manage.count.PageViewCountDao;
import com.base.cn.platform.os.entity.manage.count.PageViewCount;
import com.base.cn.platform.os.entity.manage.count.PageViewCountNum;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

/**
 * 页面PV统计Biz
 *
 * @author s.li
 * @create 2018-01-15-15:53
 */
@Service
public class PageViewCountBiz extends BaseBiz<PageViewCount,PageViewCountDao> {

    @Autowired
    private PageViewCountDao pageViewCountDao;

    /**
     * 添加页面PV统计数据
     * @param pageViewDataList
     * @throws Exception
     */
    public void addPageViewCount(List<PageViewCount> pageViewDataList){
        if(ObjectUtils.isNotEmpty(pageViewDataList)){
            this.batchSave(pageViewDataList);
        }
    }

    /**
     * 查询每个栏目访问量统计数据
     * @return 统计数据实体
     */
    public List<PageViewCountNum> queryPageViewCountNum(){
        String year = DateUtils.format(new Date(),"yyyy");
        return pageViewCountDao.queryPageViewCountNum(PageViewCount.class,year);
    }
}
